﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="原料发货录入.aspx.cs" Inherits="syc.Store.原料发货录入" %>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript" language="javascript" src="/common.js"></script>
<script src="../js/jquery.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript" >
        
        //PAGE_LOAD()
        $(document).ready(function() {
            
        $('#ZhiShu').change(function() {
                //为接箍时，运算规则成立
                if ($('#LeiBie').val() == "5" || $('#LeiBie').val() == "6" || $('#LeiBie').val() == "105" || $('#LeiBie').val() == "106") {
                    if ($('#ZhiShu').val() != "") {
                        //重量=支数*0.006  alert($('#ZhiShu').val() * 1000*0.006/1000);
                        $('#ZhongLiang').val(($('#ZhiShu').val() * 1000) * 0.006 / 1000);
                    }
                }
            });
        });						
    </script>
<form id="form1" runat="server">

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
SelectCommand="select @原料ID=原料ID,@供货ID=供货ID,@分厂=分厂,@库区=库区,@日期=日期,@重量=cast(重量 as float),@标重=cast(标重 as float),@支数=支数,@备注=备注,@规格=规格 from 原料发货记录 t1
left outer join 原料 t2 on t2.id=t1.原料ID where t1.ID=@ID;"

InsertCommand="insert into 原料发货记录(原料ID,供货ID,分厂,库区,日期,重量,标重,支数,备注,明细,车号)
values(@原料ID,@供货ID,@分厂,@库区,@日期,@重量,@标重,@支数,@备注,@明细,@车号);set @ID=@@IDENTITY;"
UpdateCommand="update 原料发货记录 set 原料ID=@原料ID,供货ID=@供货ID,分厂=@分厂,库区=@库区,日期=@日期,重量=@重量,标重=@标重,支数=@支数,备注=@备注 where ID=@ID;"
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
oninserted="SqlDataSource1_Inserted" onselected="SqlDataSource1_Selected" >
<SelectParameters>
<asp:Parameter Name="ID" DbType="Int32" Size="4" />
<asp:Parameter Name="原料ID" DbType="Int32" Size="4" Direction="Output" />
<asp:Parameter Name="供货ID" DbType="Int32" Size="4" Direction="Output" />
<asp:Parameter Name="分厂" DbType="Int32" Size="4" Direction="Output" />
<asp:Parameter Name="库区" DbType="Int32" Size="4" Direction="Output" />
<asp:Parameter Name="日期" DbType="Date" Size="3" Direction="Output" />
<asp:Parameter Name="重量" DbType="Double" Size="8" Direction="Output" />
<asp:Parameter Name="支数" DbType="Int32" Size="4" Direction="Output" />
<asp:Parameter Name="备注" DbType="String"  Size="100" Direction="Output" />
<asp:Parameter Name="规格" DbType="AnsiString" Size="40" Direction="Output" />
<asp:Parameter Name="车号" DbType="AnsiString" Size="1024" Direction="Output" />
<asp:Parameter Name="标重" DbType="Double" Size="8" Direction="Output" />
</SelectParameters>
<InsertParameters>
<asp:Parameter Name="ID" DbType="Int32" Size="4" Direction="Output" />
<asp:ControlParameter Name="原料ID" DbType="Int32" Size="4" ControlID="LeiBie"/>
<asp:ControlParameter Name="供货ID" DbType="Int32" Size="4" ControlID="GongHuo"/>
<asp:ControlParameter Name="分厂" DbType="Int32" Size="4" ControlID="FenChang" />
<asp:ControlParameter Name="库区" DbType="Int32" Size="4" ControlID="KuQu" />
<asp:ControlParameter Name="日期" DbType="Date" Size="3" ControlID="Date1" />
<asp:ControlParameter Name="重量" DbType="Decimal" Size="9" ControlID="ZhongLiang" />
<asp:ControlParameter Name="支数" DbType="Int32" Size="4" ControlID="ZhiShu" />
<asp:ControlParameter Name="备注" DbType="String"  Size="100" ControlID="BeiZhu" />
<asp:ControlParameter Name="明细" DbType="AnsiString" Size="1024" ControlID="MingXi" />
<asp:ControlParameter Name="车号" DbType="AnsiString" Size="1024" ControlID="CheHao" />
<asp:Parameter Name="保管员" DbType="String" Size="20" />
<asp:ControlParameter Name="标重" DbType="Decimal" Size="9" ControlID="BiaoZhong" />
</InsertParameters>
<UpdateParameters>
<asp:ControlParameter Name="ID" DbType="Int32" Size="4" ControlID="Label_ID"/>
<asp:ControlParameter Name="原料ID" DbType="Int32" Size="4" ControlID="LeiBie"/>
<asp:ControlParameter Name="供货ID" DbType="Int32" Size="4" ControlID="GongHuo"/>
<asp:ControlParameter Name="分厂" DbType="Int32" Size="4" ControlID="FenChang" />
<asp:ControlParameter Name="库区" DbType="Int32" Size="4" ControlID="KuQu" />
<asp:ControlParameter Name="日期" DbType="Date" Size="3" ControlID="Date1" />
<asp:ControlParameter Name="重量" DbType="Decimal" Size="9" ControlID="ZhongLiang" />
<asp:ControlParameter Name="支数" DbType="Int32" Size="4" ControlID="ZhiShu" />
<asp:ControlParameter Name="备注" DbType="String"  Size="100" ControlID="BeiZhu" />
<asp:Parameter Name="保管员" DbType="String" Size="20" />
<asp:ControlParameter Name="标重" DbType="Decimal" Size="9" ControlID="BiaoZhong" />
</UpdateParameters>
</asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
SelectCommand="select 0 as ID,'' as 名称 union all select ID, 名称 FROM 原料供货单位"></asp:SqlDataSource>

<asp:Label ID="Label_ID" runat="server" Text="0" Visible="false"></asp:Label>
<asp:Label ID="MingXi" runat="server" Text="" Visible="false"></asp:Label>
<asp:Label ID="CheHao" runat="server" Text="" Visible="false"></asp:Label>

<div id="wintop" class="wintop">原料发货</div>
<asp:Panel ID="Panel1" runat="server" CssClass="panel">
<asp:Button ID="Button_Save" runat="server" Text="保 存" UseSubmitBehavior="false" 
        CssClass="button" onclick="Button_Save_Click"/>
<input type="button" value="关 闭" class="button" onclick="parent.swin2_close();" />
</asp:Panel>
<asp:Panel ID="Panel2" runat="server" CssClass="panel">
<table border=1 height=240 style="border-collapse:separate;font-size:14px;margin-top:7px;margin-bottom:24px;">
<tr>
<td colspan=4 align=center style="font-weight:bold; letter-spacing:6px;font-size:16px;border:none;">原料发货信息</td>
</tr>
<tr>
<td align=right>使用单位：</td>
<td><asp:DropDownList ID="FenChang" Width="120px" runat="server">
    <asp:ListItem Text="" Value="0"></asp:ListItem>
    <asp:ListItem Text="一分厂" Value="1"></asp:ListItem>
    <asp:ListItem Text="二分厂" Value="2"></asp:ListItem>
    <asp:ListItem Text="三分厂" Value="3"></asp:ListItem>
    <asp:ListItem Text="四分厂" Value="4"></asp:ListItem>
    <asp:ListItem Text="五分厂" Value="5"></asp:ListItem>
</asp:DropDownList></td>
<td align=right>发货日期：</td>
<td><asp:TextBox ID="Date1" runat="server" CssClass="textbox" Width="120px"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date1').value, document.getElementById('Date1'));" /></td>
</tr>

<tr>
<td width=100 align=right>原料类别：</td>
<td width=180>
<!-- =================================================================================================== -->
<!-- ========                               原料类别列表                                     =========== -->
<!-- ========                                                                               =========== -->
<!-- =================================================================================================== -->
<asp:SqlDataSource ID="DS_LeiBie" runat="server" 
                   ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
                    SelectCommand="SELECT [ID],[品名]+' '+[钢级]+' '+[规格] AS 名称 FROM [原料]" >
</asp:SqlDataSource>
<asp:DropDownList ID="LeiBie" runat="server" Width="250px" Font-Size="12px" DataSourceID="DS_LeiBie" 
                               DataTextField="名称" DataValueField="ID">
</asp:DropDownList>
<!-- =================================================================================================== --></td>
<td width=100 align=right>规格：</td>
<td width=180><asp:Label ID="Label_GuiGe" runat="server" Text="..."></asp:Label></td>
</tr>
<tr>
<td width=100 align=right>供货单位：</td>
<td width=180><asp:DropDownList 
        ID="GongHuo" runat="server" DataSourceID="SqlDataSource2" Width="140px"
        DataTextField="名称" DataValueField="ID"></asp:DropDownList></td></td>
<td width=100 align=right>库区：</td>
<td width=180><asp:TextBox ID="KuQu" runat="server" CssClass="textbox" Width="120"></asp:TextBox></td>
</tr>
<tr>
<td align=right>重量：</td>
<td width=180><asp:TextBox ID="ZhongLiang" runat="server" CssClass="textbox" Width="120"></asp:TextBox>吨</td>
<td align=right>支数：</td>
<td width=180><asp:TextBox ID="ZhiShu" runat="server" CssClass="textbox" Width="120"></asp:TextBox>支</td>
</tr>

<tr>
<td align=right>标重：</td>
<td width=180><asp:TextBox ID="BiaoZhong" runat="server" CssClass="textbox" Width="120"></asp:TextBox>吨</td>
<td align=left colspan="2">质保书重量</td>
</tr>

<tr>
<td align=right>备注：</td>
<td colspan=3><asp:TextBox ID="BeiZhu" runat="server" CssClass="textbox" Width="300"></asp:TextBox></td>
</tr>
</table>

</asp:Panel>

</form>
<script>
    var notice = '<%=this.Notice %>';
    if (notice != '') {
        parent.showmsgbox(notice);
    }
</script>
<script>
    var textboxs = document.getElementsByTagName("input");
    var i;
    for (i = 0; i < textboxs.length; i++) {
        if (textboxs[i].className == "textbox") {
            //textboxs[i].onchange = function(e) { this.className = "textbox-changed"; };
            textboxs[i].onfocus = function(e) { this.select(); };
        }
        else if (textboxs[i].className == "pageturn" || textboxs[i].className == "intxt1" || textboxs[i].className == "intxt2") {
            textboxs[i].onfocus = function(e) { this.select(); };
        }
    }

    document.onkeydown = function(e) {
        if (!e) e = window.event;
        var tag = e.srcElement;
        if (!tag) tag = e.target;
        if (tag.tagName == "INPUT" && tag.className == "textbox" || tag.tagName == "SELECT") {
            if (e.keyCode == 13) e.keyCode = 9;
        }
    }

    function makecalendar(d, o) {
        obj = o;
        idate = makedate(d);
        cdate = new Date(idate.getFullYear(), idate.getMonth(), 1);
        ds.style.left =(getObjectLeft(o) -30) + "px";
        ds.style.top = (getObjectTop(o) - 25) + "px";
        ds.style.display = 'block';
        showcalendar();
 
    }
</script>
</body>
</html>